const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const url = require('url');
const debug = require('debug')('my-application');
const jwt = require('jsonwebtoken')
const secret = require('./secret')
// 使用 Mock
const Mock = require('mockjs');
const { v4 } = require('uuid');
const fs = require('fs');
const multer = require('multer');
app.use(express());
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
const sqlFn = require('./mysqlConfig');
const adminPermission = require('./data/admin_permission.json')
const wyfPermission = require('./data/wyf_permission.json')
const tylPermission = require('./data/tyl_permission.json')

// cors跨域处理
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "http://localhost:1314");
    res.header("Access-Control-Allow-Headers", "Content-Type,Access-Token");
    res.header("Access-Control-Allow-Methods", "PUT,GET,POST,DELETE,OPTIONS");
    res.header("X-Powerd-By", "3.2.1");
    res.header("Content-Type", "application/json;charset=utf-8");
    next();
})

/**
 * 上传图片
 */
var storage = multer.diskStorage({
    destination: function (req, file, cb) {
        cb(null, "./upload/")
    },
    filename: function (req, file, cb) {
        cb(null, Date.now() + "-" + file.originalname)
    }
})

var createFolder = function (folder) {
    try {
        fs.accessSync(folder);
    } catch (e) {
        fs.mkdirSync(folder);
    }
}

var uploadFolder = './upload/';
createFolder(uploadFolder);
var upload = multer({ storage: storage });

app.post('/upload', upload.single('file'), function (req, res, next) {
    var file = req.file;
    console.log('文件类型：%s', file.mimetype);
    console.log('原始文件名：%s', file.originalname);
    console.log('文件大小：%s', file.size);
    console.log('文件保存路径：%s', file.path);
    res.json({ res_code: '0', name: file.originalname, url: file.path });
});

// admin权限
app.get("/permission", (req, res) => {
    const aname = url.parse(req.url, true).query.aname;
    if (aname === 'admin') {
        res.send(adminPermission)
    }
    if (aname === "王圆锋") {
        res.send(wyfPermission)
    }
    if (aname === "涂亚伦") {
        res.send(tylPermission)
    }
})

// 后台侧边导航
app.get('/menu', (req, res) => {
    var pid = url.parse(req.url, true).query.pid;
    var sql = "select * from t_menu where pid=?";
    sqlFn(sql, [pid], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 后台主持人管理
app.get('/host/manager', (req, res) => {
    const sql = "select * from t_host join t_host_power on t_host.hid=t_host_power.hostid";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 添加主持人
app.get('/host/add', (req, res) => {
    var hname = url.parse(req.url, true).query.hname;
    var hpwd = url.parse(req.url, true).query.hpwd;
    var hphone = url.parse(req.url, true).query.hphone;
    var hemail = url.parse(req.url, true).query.hemail;
    const sql = "insert into t_host values(null,?,?,?,?,?,1,0,0)";
    const arr = [hname, hpwd, hphone, hemail, new Date()];
    sqlFn(sql, arr, result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '主持人添加成功',
            })
        } else {
            res.status(400).json({
                errors: '主持人添加失败'
            })
        }
    })
})

// 主持人等级管理
app.get('/host/rank', (req, res) => {
    res.send({
        msg: 'success',
        status: 200,
        list: [
            {
                id: v4(),
                classname: '首席主持人',
                minPrice: 9000,
                maxPrice: 20000
            },
            {
                id: v4(),
                classname: '高端主持人',
                minPrice: 6000,
                maxPrice: 9000
            },
            {
                id: v4(),
                classname: '资深主持人',
                minPrice: 4000,
                maxPrice: 6000
            },
            {
                id: v4(),
                classname: '专业主持人',
                minPrice: 2000,
                maxPrice: 4000
            },
        ]
    })
})

// 登录
app.post('/new/login', (req, res) => {
    const { username, password, role } = req.body;
    if (username == "admin" || username == "王圆锋" || username == "涂亚伦") {
        const sql = "select * from t_admin where `aname` = ? and `apwd` = ?";
        const arr = [username, password];
        sqlFn(sql, arr, result => {
            if (result.length > 0) {
                res.status(200).json({
                    msg: '登录成功',
                    type: 'admin'
                });
            } else {
                res.status(400).json({
                    errors: '用户名或者密码错误'
                })
            }
        })
    } else {
        let sql = '';
        switch (role) {
            case "新人":
                sql = "select * from t_married_person where `pname`=? and `ppwd`=?"
                break;
            case "主持人":
                sql = "select * from t_host where `hname`=? and `hpwd`=?"
                break;
            case "婚庆公司":
                sql = "select * from t_company where `cname`=? and `cpwd`=?"
                break;
            case "策划师":
                sql = "select * from t_planner where `nname`=? and `npwd`=?"
                break;
        }
        sqlFn(sql, [username, password], result => {
            if (result.length > 0) {
                var token = '';
                if (role == "新人") {
                    token = jwt.sign({
                        pid: result[0].pid,
                        username: result[0].pname
                    }, secret.jwtSecret)
                }
                if (role == "主持人") {
                    token = jwt.sign({
                        hid: result[0].hid,
                        username: result[0].hname
                    }, secret.jwtSecret)
                }
                if (role == "婚庆公司") {
                    token = jwt.sign({
                        cid: result[0].cid,
                        username: result[0].cname
                    }, secret.jwtSecret)
                }
                if (role == "策划师") {
                    token = jwt.sign({
                        nid: result[0].nid,
                        username: result[0].nname
                    }, secret.jwtSecret)
                }
                res.status(200).json({
                    msg: role + '登录成功',
                    token,
                    role,
                    type: 'web'
                });
            } else {
                res.status(400).json({
                    errors: '用户名或者密码错误'
                })
            }
        })
    }
})

// 后台管理员登录
app.post('/login', (req, res) => {
    const { username, password } = req.body;
    const sql = "select * from t_admin where `aname` = ? and `apwd` = ?";
    const arr = [username, password];
    sqlFn(sql, arr, result => {
        if (result.length > 0) {
            if (username === 'admin') {
                res.status(200).json({
                    msg: '登录成功',
                    data: {
                        token: "admin"
                    }
                });
            }
            if (username === '王圆锋') {
                res.status(200).json({
                    msg: '登录成功',
                    data: {
                        token: "wyf"
                    }
                });
            }
            if (username === '涂亚伦') {
                res.status(200).json({
                    msg: '登录成功',
                    data: {
                        token: "tyl"
                    }
                });
            }
        } else {
            res.status(400).json({
                errors: '用户名或者密码错误'
            })
        }
    })
})

// 前台登录 新人，主持人，婚庆公司，策划师
app.post('/protal/login', (req, res) => {
    const { username, password, role } = req.body;
    let sql = '';
    switch (role) {
        case "新人":
            sql = "select * from t_married_person where `pname`=? and `ppwd`=?"
            break;
        case "主持人":
            sql = "select * from t_host where `hname`=? and `hpwd`=?"
            break;
        case "婚庆公司":
            sql = "select * from t_company where `cname`=? and `cpwd`=?"
            break;
        case "策划师":
            sql = "select * from t_planner where `nname`=? and `npwd`=?"
            break;
    }
    sqlFn(sql, [username, password], result => {
        if (result.length > 0) {
            var token = '';
            if (role == "新人") {
                token = jwt.sign({
                    pid: result[0].pid,
                    username: result[0].pname
                }, secret.jwtSecret)
            }
            if (role == "主持人") {
                token = jwt.sign({
                    hid: result[0].hid,
                    username: result[0].hname
                }, secret.jwtSecret)
            }
            if (role == "婚庆公司") {
                token = jwt.sign({
                    cid: result[0].cid,
                    username: result[0].cname
                }, secret.jwtSecret)
            }
            if (role == "策划师") {
                token = jwt.sign({
                    nid: result[0].nid,
                    username: result[0].nname
                }, secret.jwtSecret)
            }
            res.status(200).json({
                msg: role + '登录成功',
                token,
                role
            });
        } else {
            res.status(400).json({
                errors: '用户名或者密码错误'
            })
        }
    })
})


// 管理员查询
app.get('/selectAdmin', (req, res) => {
    const sql = "select * from t_admin";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 后台管理员添加
app.get('/register', (req, res) => {
    var aname = url.parse(req.url, true).query.aname;
    var apwd = url.parse(req.url, true).query.apwd;
    var aphone = url.parse(req.url, true).query.aphone;
    var permission = url.parse(req.url, true).query.permission;
    const sql = "insert into t_admin values(null,?,?,?,?,?)";
    const arr = [aname, apwd, aphone, permission, new Date()];
    sqlFn(sql, arr, result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '管理员添加成功',
            })
        } else {
            res.status(400).json({
                errors: '管理员添加失败'
            })
        }
    })
})

// 管理员编辑时预更新接口
app.get('/pre/adminUpdate', (req, res) => {
    var aid = url.parse(req.url, true).query.aid;
    const sql = "select * from t_admin where aid=?";
    sqlFn(sql, [aid], result => {
        if (result.length > 0) {
            res.send({
                status: 200,
                result
            })
        } else {
            res.send({
                status: 500,
                msg: '预更新失败'
            })
        }
    })
})

// 管理员编辑
app.get('/adminUpdate', (req, res) => {
    var aid = url.parse(req.url, true).query.aid;
    var aname = url.parse(req.url, true).query.aname || '';
    var apwd = url.parse(req.url, true).query.apwd || '';
    var aphone = url.parse(req.url, true).query.aphone || '';
    const sql = "update t_admin set aname=?,apwd=?,aphone=? where aid=?";
    sqlFn(sql, [aname, apwd, aphone, aid], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '修改成功'
            })
        } else {
            res.status(400).json({
                msg: '修改失败'
            })
        }
    })
})

// 管理员删除
app.get('/adminDelete', (req, res) => {
    var aid = url.parse(req.url, true).query.aid;
    var sql = "delete from t_admin where aid=?";
    sqlFn(sql, [aid], result => {
        if (result.affectedRows > 0) {
            res.send({
                status: 200,
                msg: '删除成功'
            })
        } else {
            res.send({
                status: 400,
                msg: '删除失败'
            })
        }
    })
})

// 婚庆公司查询
app.get('/selectCompany', (req, res) => {
    const sql = "select * from t_company";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 添加公司
app.get('/addCompany', (req, res) => {
    var cpwd = url.parse(req.url, true).query.cpwd;
    var cname = url.parse(req.url, true).query.cname;
    var ceo = url.parse(req.url, true).query.ceo;
    var cphone = url.parse(req.url, true).query.cphone;
    var cmail = url.parse(req.url, true).query.cmail;
    const sql = "insert into t_company values(null,?,?,?,?,?,?,2,0)";
    sqlFn(sql, [cpwd, cname, ceo, cphone, cmail, new Date()], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '添加成功'
            })
        } else {
            res.status(400).json({
                msg: '添加失败'
            })
        }
    })
})

// 新人查询
app.get('/selectPerson', (req, res) => {
    const sql = "select * from t_married_person";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 新人编辑预更新
app.get('/pre/updateNew', (req, res) => {
    var pname = url.parse(req.url, true).query.pname;
    const sql = "select * from t_married_person where pname=?";
    sqlFn(sql, [pname], result => {
        if (result.length > 0) {
            res.send({
                status: 200,
                result
            })
        } else {
            res.send({
                status: 500,
                msg: '预更新失败'
            })
        }
    })
})

// 新人编辑
app.get('/updateNew', (req, res) => {
    var pname = url.parse(req.url, true).query.pname;
    var pphone = url.parse(req.url, true).query.pphone;
    var pmail = url.parse(req.url, true).query.pmail;
    var ppwd = url.parse(req.url, true).query.ppwd;
    const sql = "update t_married_person set ppwd=?,pphone=?,pmail=? where pname=?";
    sqlFn(sql, [ppwd, pphone, pmail, pname], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '修改成功'
            })
        } else {
            res.status(400).json({
                msg: '修改失败'
            })
        }
    })
})

// 主持人订单中心
app.get('/host/orderCenter', (req, res) => {
    const sql = "select * from t_host_order join t_married_person on t_host_order.pid = t_married_person.pid join t_company on t_host_order.cid = t_company.cid join t_host on t_host_order.hid = t_host.hid";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 主持人查询
app.get('/selectHost', (req, res) => {
    const sql = "select * from t_host";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 后台管理员添加主持人
app.post('/add/host', (req, res) => {
    const { username, password, phone, email } = req.body;
    const sql = "insert into t_host values(null,?,?,?,?,?)";
    const arr = [username, password, phone, email, new Date(), 1, ''];
    sqlFn(sql, arr, result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '主持人添加成功',
            })
        } else {
            res.status(400).json({
                errors: '主持人添加失败'
            })
        }
    })
})

// 合作伙伴增删查改
// 合作伙伴查(前后通用)
app.get('/selectPartner', (req, res) => {
    const sql = "select * from t_partner order by id asc";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 合作伙伴增
app.get('/addPartner', (req, res) => {
    var name = url.parse(req.url, true).query.name;
    var logo = url.parse(req.url, true).query.logo;
    var purl = url.parse(req.url, true).query.purl;
    const sql = "insert into t_partner values(null,?,?,?)";
    sqlFn(sql, [name, logo, purl], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '添加成功'
            })
        } else {
            res.status(400).json({
                msg: '添加失败'
            })
        }
    })
})


// 合作伙伴修改
app.get('/updatePartner', (req, res) => {
    var id = url.parse(req.url, true).query.id;
    var name = url.parse(req.url, true).query.name;
    var logo = url.parse(req.url, true).query.logo;
    var purl = url.parse(req.url, true).query.purl;
    const sql = "update t_partner set name=?,logo=?,purl=? where id=?";
    sqlFn(sql, [name, logo, purl, id], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '修改成功'
            })
        } else {
            res.status(400).json({
                msg: '修改失败'
            })
        }
    })
})


// 合作伙伴删除
app.get('/deletePartner', (req, res) => {
    var id = url.parse(req.url, true).query.id;
    var sql = "delete from t_partner where id=?";
    sqlFn(sql, [id], result => {
        if (result.affectedRows > 0) {
            res.send({
                status: 200,
                msg: '删除成功'
            })
        } else {
            res.send({
                status: 400,
                msg: '删除失败'
            })
        }
    })
})

// 策划师列表
app.get('/select/planner', (req, res) => {
    const cid = url.parse(req.url, true).query.cid;
    const sql = "select * from t_planner where cid=?";
    sqlFn(sql, [cid], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// 前台注册 婚庆公司
app.post('/company/register', (req, res) => {
    const { cname, ceo, cpwd, cphone, cemail } = req.body;
    const sql = "insert into t_company values(null,?,?,?,?,?,?,2,'')";
    const arr = [cpwd, cname, ceo, cphone, cemail, new Date()];
    sqlFn(sql, arr, result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '公司注册成功，请等待审核',
            })
        } else {
            res.status(400).json({
                errors: '公司注册失败'
            })
        }
    })
})

// 前台注册 新人
app.post('/marry/person', (req, res) => {
    const { pname, ppwd, pphone, pemail, marrydate } = req.body;
    const sql = "insert into t_married_person values(null,?,?,?,?,?,?,1)";
    const arr = [pname, ppwd, pphone, pemail, marrydate, new Date()];
    sqlFn(sql, arr, result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '新人注册成功',
            })
        } else {
            res.status(400).json({
                errors: '新人注册失败'
            })
        }
    })
})


// 前台轮播图接口
app.get('/banners', (req, res) => {
    const sql = "select * from t_banner";
    sqlFn(sql, [], result => {
        if (result.length > 0) {
            res.status(200).json(result)
        } else {
            res.status(400).json({
                msg: '暂无数据'
            })
        }
    })
})

// banner添加
app.get('/banners/add', (req, res) => {
    var title = url.parse(req.url, true).query.title;
    var burl = url.parse(req.url, true).query.burl;
    var content = url.parse(req.url, true).query.content;
    const sql = "insert into t_banner values(null,?,?,?,?)";
    sqlFn(sql, [title, burl, content, new Date()], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '添加成功'
            })
        } else {
            res.status(400).json({
                msg: '添加失败'
            })
        }
    })
})

// banner编辑
app.get('/banners/update', (req, res) => {
    var id = url.parse(req.url, true).query.id;
    var title = url.parse(req.url, true).query.title;
    var burl = url.parse(req.url, true).query.burl;
    var content = url.parse(req.url, true).query.content;
    const sql = "update t_banner set title=?,burl=?,content=? where id=?";
    sqlFn(sql, [title, burl, content, id], result => {
        if (result.affectedRows > 0) {
            res.status(200).json({
                msg: '修改成功'
            })
        } else {
            res.status(400).json({
                msg: '修改失败'
            })
        }
    })
})

// banner删除
app.get('/banners/delete', (req, res) => {
    var id = url.parse(req.url, true).query.id;
    var sql = "delete from t_banner where id=?";
    sqlFn(sql, [id], result => {
        if (result.affectedRows > 0) {
            res.send({
                status: 200,
                msg: '删除成功'
            })
        } else {
            res.send({
                status: 400,
                msg: '删除失败'
            })
        }
    })
})

// 前台每日推荐主持人
app.get('/recommend/host', (req, res) => {
    return res.send(Mock.mock({
        msg: '请求成功',
        status: 200,
        'list|20': [
            {
                id: function () {
                    return v4();
                },
                name: '@cname(2,3)',
                price: '@integer(20,100)' + '00',
                'type|1': ['八折', '星推荐'],
                order: '@integer(80,150)',
                'img|+1': [
                    'http://www.tingyu818.com/profile/avatar/2020/07/27/bb92e302a04392231835ee66973b853f.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/23/3656a7f51eaeaa94e65862478fc8600a.png',
                    'http://www.tingyu818.com/profile/avatar/2020/07/25/86b1ee809abe418342b25f81a1e18a3d.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/23/fb64ce4e5d6aa430c9c7b4dd89077ed6.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/24/667fe2c09b51de0e8cfa78af8a0bd361.png',
                    'http://www.tingyu818.com/profile/avatar/2019/08/04/16a81cb8f6731ebc21049fc0fd025f50.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/01/03/ffdd6b2d45b70371b4485b3e2750893e.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/07/24/3adec707126795551b25d1b9a452a800.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/12/05/0c313679c2c02075f9effd95778980df.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/12/13/f7352b1c13093ce0aef163d212156693.png',
                    'http://www.tingyu818.com/profile/avatar/2020/07/27/bb92e302a04392231835ee66973b853f.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/23/3656a7f51eaeaa94e65862478fc8600a.png',
                    'http://www.tingyu818.com/profile/avatar/2020/07/25/86b1ee809abe418342b25f81a1e18a3d.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/23/fb64ce4e5d6aa430c9c7b4dd89077ed6.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/07/24/667fe2c09b51de0e8cfa78af8a0bd361.png',
                    'http://www.tingyu818.com/profile/avatar/2019/08/04/16a81cb8f6731ebc21049fc0fd025f50.jpg',
                    'http://www.tingyu818.com/profile/avatar/2020/01/03/ffdd6b2d45b70371b4485b3e2750893e.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/07/24/3adec707126795551b25d1b9a452a800.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/12/05/0c313679c2c02075f9effd95778980df.jpg',
                    'http://www.tingyu818.com/profile/avatar/2019/12/13/f7352b1c13093ce0aef163d212156693.png',
                ],
                age: "@integer(25,35)",
                height: "@integer(170,190)",
                weight: "@integer(60,80)",
                phone: /^1[3456789]\d{9}$/,
                remark: '五环外+300元，外地+1000元',
                introduction: "@cparagraph(10,20)"
            }
        ]
    }))
})


// 关于我们
app.get('/about', (req, res) => {
    res.send({
        msg: 'success',
        status: 200,
        about: {
            title: "关于我们",
            content: '北京Ting域主持人团队成立于2019年1月，是一支集婚礼主持，商务主持于一体的综合性主持人团队，团队内部主持人均在行业内有三年以上的主持经验，舞台阅历丰富，与北京地区各大婚庆公司均有合作，Ting域主持人团队有统一的执行标准，完善的管理制度，经过近一年的运行，现已基本形成“主持人服务流程标准化”，北京地区人均年接单量60+，目前团队已初具规模，全力打造“服务至上”的团队文化，以“新人满意度”为衡量主持人能力的标准，相信我们的出现一定会给现在不太“景气”的这个行业带来一缕春风。Ting域，听到更温暖的声音，听到更感动的故事，遇到更好的你们。',
            img: 'http://www.tingyu818.com/tingyu/img/%E4%B8%BB%E6%8C%81%E4%BA%BA_%E5%85%B3%E4%BA%8E%E6%88%91%E4%BB%AC_08.jpg'
        },
        applyFor: {
            title: "我们的服务",
            list: [{
                id: v4(),
                title: "专业",
                text: "人均300场的主持经验，由量的积累到质的飞跃，我们用专业为您的婚礼保驾护航！",
                backgroundImg: 'http://www.tingyu818.com/tingyu/img/kg1111.png',
                img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201.png'
            },
            {
                id: v4(),
                title: "定制",
                text: "每一对新人都有自己独一无二的爱情故事，同样我们认为，每一场婚礼应该有其专属的流程，更应该有一套专属每对新人的婚礼主持词！",
                backgroundImg: 'http://www.tingyu818.com/tingyu/img/bk_2222.png',
                img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D%202.png'
            },
            {
                id: v4(),
                title: "匠心",
                text: "我们绝不满足于曾经的主持成果与经验，我们坚信婚礼还原爱情本真的同时更应该有诸多的形式来展现，我们坚持用一颗匠心为每一对新人主持，呈现铭记一生的浪漫回忆！",
                backgroundImg: 'http://www.tingyu818.com/tingyu/img/kg1111.png',
                img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D%203.png'
            },
            {
                id: v4(),
                title: "创新",
                text: "主持人不再是那种高高在上的形象，更应该走进新人的内心，挖掘、收集他们的爱情点滴，以朋友的身份和形式讲述专属于他们的爱情故事，以不同形式和环节创意为新人造梦，化腐朽为神奇是我们坚持的初心！",
                backgroundImg: 'http://www.tingyu818.com/tingyu/img/bk_2222.png',
                img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D.png'
            },
            ]
        }

    })
})

//加入我们
app.get('/joinus', (req, res) => {
    res.send({
        msg: 'success',
        status: 200,
        about: {
            title1: "加入我们",
            content1: '如果你也向往舞台，不甘平庸；',
            content2: '如果你还在单打独斗，还是散兵游勇；',
            content3: '如果你也相信团队的力量，给自己一次机会，加入我们，蜕变从这开始。',
            content4: 'Ting域，听到更好的…',
            title2: '希望你：',
            content5: '一、常驻北京',
            content6: '二、标准的普通话',
            content7: '三、良好的个人形象',
            content8: '四、播音主持相关专业优先',
        },
        applyFor: {
            title: "我们的优势",
            list: [
                {
                    id: v4(),
                    title: "和谐",
                    text: "和谐的氛围！",
                    backgroundImg: 'http://www.tingyu818.com/tingyu/img/kg1111.png',
                    img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201.png'
                },
                {
                    id: v4(),
                    title: "资源",
                    text: "优质的资源！",
                    backgroundImg: 'http://www.tingyu818.com/tingyu/img/bk_2222.png',
                    img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D%202.png'
                },
                {
                    id: v4(),
                    title: "超值",
                    text: "超低的管理费！",
                    backgroundImg: 'http://www.tingyu818.com/tingyu/img/kg1111.png',
                    img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D%203.png'
                },
                {
                    id: v4(),
                    title: "提升",
                    text: "一线顾问指导！完善的晋级制度！",
                    backgroundImg: 'http://www.tingyu818.com/tingyu/img/bk_2222.png',
                    img: 'http://www.tingyu818.com/tingyu/img/%E6%A4%AD%E5%9C%86%201%20%E6%8B%B7%E8%B4%9D.png'
                },
            ]
        }

    })
})

// 底部文案，二维码设置
app.get('/bottom', (req, res) => {
    res.send({
        msg: 'success',
        status: 200,
        headgreet: 'Ting域主持人欢迎您！ 客服：13601371065（卓越老师）',
        phone: '18812345678',
        address: '北京市长安街天安门1号',
        copyrigth: '京ICP备19033509号  版权归Ting域主持人团队所有',
        QRcode: 'http://www.tingyu818.com/tingyu/img/publicWeChat1.jpg'
    })
})

app.listen(1314, () => {
    console.log(1314);
    debug(1314);
})